<?php

namespace app\model;
use think\model\relation\BelongsTo;

/**
 * @mixin \think\Model
 */
class AdminRechargeRecord extends Base
{
    //
    protected $autoWriteTimestamp = true;

    const ORDER_TYPE = [0 => '水表充值',1=>'电表充值'];

    public function getOrderTypeTextAttr($value, $data)
    {
        $type = self::ORDER_TYPE;
        return $type[$data['order_type']] ?? '';
    }

    public function school(): BelongsTo {
        return $this->belongsTo(AdminSchool::class, 'school_id')->bind([
            'school_name' => 'name'
        ]);
    }

    public function staff(): BelongsTo {
        return $this->belongsTo(AdminStaff::class, 'staff_id')->bind([
            'staff_name' => 'name',
            'staff_type' => 'type',
            'staff_type_text' => 'type_text',
            'student_no',
            'sex',
            'phone'
        ]);
    }
}
